package com.atstudy.log;

import org.aspectj.lang.ProceedingJoinPoint;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Repository;
import org.springframework.stereotype.Service;

/**
 * @version v1.0
 * @description:
 * @author: admin
 * @date: 2023/2/13 14:53
 * @copyright: 博为峰
 */
@Component("logger")
public class Logger {

    public void beforeLog() {
        System.out.println("前置通知");
    }

    public void afterReturning() {
        System.out.println("后置通知");
    }

    public void after() {
        System.out.println("最终通知");
    }

    public void afterThrowing() {
        System.out.println("异常通知");
    }

    public void around(ProceedingJoinPoint point) {
        try {
            System.out.println("环绕-前置通知");
            point.proceed();//调业务方法
            System.out.println("环绕-后置通知");
        } catch (Throwable throwable) {
            System.out.println("环绕-异常通知");
        } finally {
            System.out.println("环绕-最终通知");
        }
    }

}
